package service

import (
	"daily-blog/dao"
	"daily-blog/global"
	"daily-blog/model"
	"daily-blog/pkg"
)

func CreateUser(user *model.User) bool {
	user.UserId = pkg.GenUUID()
	user.UserPassword = pkg.Encrypt(user.UserPassword)
	if err := dao.CreateUser(user); err != nil {
		global.GVA_LOG.Error(err.Error())
		return false
	}
	return true
}
func GetUserByNamePwd(name, pwd string) (string, bool) {
	pwd = pkg.Encrypt(pwd)
	userId, err := dao.GetUserByNamePwd(name, pwd)
	if err != nil {
		global.GVA_LOG.Error(err.Error())
		return "", false
	}
	return userId, true
}
